<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增公告内容')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-content-add">

        <!--
                           th:text="${type.typeName}  给标签  添加文本显示内容
                           th:value="${type.typeId} 只能给表单 显示内容
-->
        <!--       <span th:text="${type.typeName}"></span-->
        <div class="form-group">
            <div class="form-group">
                <label class="col-sm-3 control-label"> 公告类型的名称：</label>
                <!--				这里通过select 标签显示 公告类型 页面传送过来  -->
                <div class="col-sm-9">
                    <select class="form-control" name="typeId">
                        <option th:each="type:${opts}" th:value="${type.typeId}">
<!--                            <span th:text="${type.typeName}"></span>-->
                            [[${type.typeName}]]
                        </option>
                    </select>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">公告内容的标题：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="contentTitle" id="contentTitle" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">公告内容:</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="contentText" id="contentText" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script type="text/javascript">

    //前缀
    var prefix = ctx + "cms/content";

    $("#form-content-add").validate({
        onkeyup: false,

        // 表单校验
        rules: {
            contentTitle: {
                remote: {
                    //发送请求的url
                    url: prefix + "/checkContentTitleUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "contentTitle": function () {
                            return $.common.trim($("#contentTitle").val());
                        }
                    },
                    dataFilter: function (data, type) {
                        return $.validate.unique(data);
                    }
                }
            },

        },
        //信息提示
        messages: {
            "contentTitle": {
                remote: "公告内容标题已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-content-add').serialize());
        }
    }
</script>
</body>
</html>
